package net.lab1024.sa.admin.module.business.exam.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import net.lab1024.sa.admin.module.business.exam.domain.entity.CourseEntity;
import net.lab1024.sa.admin.module.business.exam.domain.form.add.CourseAddForm;
import net.lab1024.sa.admin.module.business.exam.domain.form.query.CourseQueryForm;
import net.lab1024.sa.admin.module.business.exam.domain.form.update.CourseUpdateForm;
import net.lab1024.sa.admin.module.business.exam.domain.vo.CourseVO;
import net.lab1024.sa.admin.module.business.exam.service.CourseService;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 课程分类 Controller
 *
 * @Author AKITA
 * @Date 2025-05-22 15:22:00
 * @Copyright AKITA
 */

@RestController
@Tag(name = "课程分类")
public class CourseController {

    @Resource
    private CourseService courseService;

    @PostMapping("/course/queryPage")
    public ResponseDTO<PageResult<CourseVO>> queryPage(@RequestBody @Valid CourseQueryForm queryForm) {
        return ResponseDTO.ok(courseService.queryPage(queryForm));
    }

    @PostMapping("/course/add")
    public ResponseDTO<Long> add(@RequestBody @Valid CourseAddForm addForm) {
        return courseService.add(addForm);
    }

    @PostMapping("/course/update")
    public ResponseDTO<String> update(@RequestBody @Valid CourseUpdateForm updateForm) {
        return courseService.update(updateForm);
    }

    @PostMapping("/course/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return courseService.batchDelete(idList);
    }

    @GetMapping("/course/delete/{docEntry}")
    public ResponseDTO<String> batchDelete(@PathVariable Long docEntry) {
        return courseService.delete(docEntry);
    }

    @GetMapping("/course/openAll/{docEntry}")
    public ResponseDTO<CourseEntity> openAll(@PathVariable Long docEntry) {
        return courseService.openAll(docEntry);
    }

    @PostMapping("/course/myList")
    public ResponseDTO<List<CourseEntity>> myList(@RequestBody CourseQueryForm queryForm) {
        return courseService.myList(queryForm);
    }

    @GetMapping("/course/info/{docEntry}")
    public ResponseDTO<CourseEntity> info(@PathVariable Long docEntry) {
        return courseService.info(docEntry);
    }

    @GetMapping("/course/myInfo/{docEntry}")
    public ResponseDTO<CourseEntity> myInfo(@PathVariable Long docEntry) {
        return courseService.myInfo(docEntry);
    }

}
